///////////////////////////////////////////////////////////////////////////////
// This file is taken directly from pyR, (C) Nial Peters 2011
//
// Copyright (C) Nial Peters 2012
//
// This file is part of AvoScan.
//
// AvoScan is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// AvoScan is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with AvoScan.  If not, see <http://www.gnu.org/licenses/>.
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#include"pyr_error.h"

pyr_error_t pyr_error;

#ifdef PYTHON_BUILD
inline PyObject * GET_PYTHON_EXC(void){
	//returns the python exception corresponding to the error code set
	switch (pyr_error.type){
		case ERR:
			return PyExc_Exception;

		case IO_ERR:
			return PyExc_IOError;

		case VALUE_ERR:
			return PyExc_ValueError;

		case TYPE_ERR:
			return PyExc_TypeError;

		case RUN_ERR:
			return PyExc_RuntimeError;

		case MEM_ERR:
			return PyExc_MemoryError;

		default:
			FATAL("Request for Python exception for unknown error code. Or no error set.");
	}
}
#endif
